﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Dynamic;
using System.ComponentModel;
using CCH.Entity;


namespace CCH.DAO
{
    [DataObject(true)]
    public class messagefileDAO
    {
        private Entities model = new Entities();

        public IQueryable<messagefile> Get_messagefile_AllData(int mes_no)
        {
            return (from d in model.messagefile where d.mess_no == mes_no orderby d.file_no select d);
        }

        public IQueryable<messagefile> Get_message_AllData(int mes_no, int startRowIndex, int maximumRows)
        {
            return Get_messagefile_AllData(mes_no).Skip(startRowIndex).Take(maximumRows);
        }

        public int Get_message_AllData_Count(int mes_no)
        {
            return Get_messagefile_AllData(mes_no).Count();
        }

        public messagefile Get_messagefile(int file_no)
        {
            return (from d in model.messagefile where d.file_no == file_no select d).FirstOrDefault();
        }

        public void Add_messagefile(messagefile d)
        {
            model.messagefile.AddObject(d);
            Update();
        }

        public void Delete_messagefile(int file_no)
        {
            model.messagefile.DeleteObject(Get_messagefile(file_no));
            Update();
        }

        public void Update()
        {
            model.SaveChanges();
        }
    }
}
